home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 17 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.1 KB  |  111 lines

  1. Path: news.packet.net!usenet
  2. From: mrivers@tbag.org (Michael Rivers)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Listview Problem
  5. Date: Mon, 1 Jan 96 02:19:58 EST
  6. Organization: TBAG
  7. Distribution: world
  8. Message-ID: <19960101.3BC8A8.2C05@tbag.org>
  9. NNTP-Posting-Host: tbag.org
  10.  
  11. JL> I am trying to make a listview gadget.  I have followed the RKM's as
  12. JL> close as possible.  I am able to get the listview to show up on my
  13. JL> window, but the text that goes in the listview is not there.  I have
  14. JL> made
  15. JL> a node list and named each one.  The slider knob is the right size for
  16. JL> the number of nodes in the list.  What am I missing...
  17.  
  18. JL> This is a repeat post because I think I removed the last one.  In the
  19. JL> previous post, someone replied to put source code up.  here goes:
  20.  
  21. After building the List & Nodes you need to:
  22.    **************************************************************
  23. GT_SetGadgetAttrs(lvgadget,xwindow,0,GTLV_Labels,namelist,TAG_DONE);
  24.    **************************************************************
  25.  
  26. JL> void makelabels(void)
  27. JL> {
  28. JL>   size_t q;
  29. JL>   char x;
  30.  
  31. JL>   xtype = 0;
  32. JL>   xfp = (FILE *)fopen("Xenolink:users/Userfile.xlk","rb+");
  33. JL>   fseek(xfp, sizeof(struct User), SEEK_SET);
  34.  
  35. JL>   namelist = (struct List *)AllocVec(sizeof(struct MinList), 
  36.                                          ^^^^^^^^^*1^^^^^^^^^^^
  37. JL>   MEMF_CLEAR|MEMF_CHIP);
  38.                  ^^^^^^^^^^
  39.  
  40. This is wrong.  should be AllocVec(sizeof(struct List)...(see *2 below)
  41. Also, you should remove the MEMF_CHIP flags.  It may need the MEMF_PUBLIC
  42. flag, however, I am not sure.
  43.  
  44. JL>   if(!namelist)
  45. JL>   {
  46. JL>     printf("Error: Allocating Memory for List!\n");
  47. JL>     exit(0);
  48. JL>   }
  49. JL>   else
  50. JL>   {
  51. JL>     namelist->lh_Type=32;
  52.         ^^^^^^^*2^^^^^^^^^^^^
  53. This is a no-no. (see *1)  You've allocated only enough mem for a MinList,
  54. however your using it as a List, and you accessing ram you don't own.
  55.  
  56. JL>     NewList((struct List *)namelist);
  57.                 ^^^^^^^^^^^^^^^ not neccessary.
  58. JL>   }
  59.  
  60. /* below here is a replacement for your do/while loop.*/
  61.  
  62. ...
  63.  
  64. while(q = fread(&xuser, sizeof(struct User), 1L, xfp));
  65. {
  66.   if(q==sizeof(struct User))
  67.   {
  68.     if(namenode=AllocNamedNode(xuser.Name))  /* See below */
  69.     {
  70.       namenode->ln_Type = 100;
  71.       AddTail((struct List *)namelist, (struct Node *)namenode);
  72.     }
  73.     else
  74.     {
  75.       /* do error handling stuff here */
  76.     } 
  77.   }
  78. }
  79.  
  80. ...
  81.  
  82.  
  83. /*---Be sure to make a prototype-------*/
  84.  
  85. struct Node *AllocNamedNode(STRPTR Name)
  86. {
  87.   struct Node *n;
  88.  
  89.   if(n=AllocVec(sizeof(struct Node),MEMF_CLEAR|MEMF_PUBLIC))
  90.   {
  91.     if(n->ln_Name=AllocVec(strlen(Name)+1,MEMF_CLEAR|MEMF_PUBLIC))
  92.     {
  93.       strcpy(n->ln_Name,Name);
  94.       return(n)
  95.     }
  96.     FreeVec(n)
  97.   }
  98.   return(0);
  99. }
  100.  
  101.  
  102. ╖---------------------------------------------------------╖
  103. | Commodore failure. Press left mouse button to continue  |
  104. |       Error:  $0100000C       Task : $416C6920          |
  105. ╖---------------------------------------------------------╖
  106.     Mike Rivers (aka) Vermin --  mrivers@tbag.tscs.com
  107.           A4000/040 25mhz  18megs  1,451meg hd
  108.  
  109. ... Windows, If swallowed, do not induced vomiting.
  110.  * Q-Blue 2.0 [NR] *
  111.